<template>
  <div class="operating_password">
    <Modal
      @on-cancel="cancelClick"
      @on-ok="operation_password"
      :ok-text="$t('views.public.sure')"
      :cancel-text="$t('views.public.cancel')"
      v-model="showModal"
      :title="$t('components.publicCheckPassword.checkPassword')">
<!--      <i-input :type="showModal?'password':''" v-model="reason"></i-input>-->
    </Modal>
  </div>
</template>

<script>
  import { mapGetters } from 'vuex';

  export default {
    name: "operating_password",
    components: {},
    data() {
      return {
        reason: '',
        showModal: false,
      }
    },
    computed: {
      ...mapGetters(['showPasswordFlag']),
    },
    created() {
    },
    methods: {
      operation_password() {
        this.$http.checkAdminPwd({
          password: this.reason,
        }).then((res) => {
          if (Number(res.status) == 200) {
            this.$Message.info($t('components.publicCheckPassword.checkSuccess'));
          } else {
            this.$Message.error(res.msg)
          }
          this.reason = '';
        }).catch(err => {
          this.reason = '';
        })
        this.$store.commit('setShowPasswordFlag', false);
      },
      cancelClick() {
        this.$store.commit('setShowPasswordFlag', false);
      }
    },
    watch: {
      showPasswordFlag(newVal) {
        if (newVal) {
          this.showModal = true;
        }
      },
    }
  }
</script>
<style scoped lang="scss">
  @function r($px) {
    @return $px/100*1rem;
  }
</style>
